{extend name="ashippingguide/Public/base" /}
{block name="container"}
<div class="page-heade">
    <h2 class="title_color text-center">导购目标格式管理</h2>
</div>
<div class="col-md-12 mtp no-padding">
    <form action="{:url('editformatform')}" id="f1" class="form-inline" method="post">
        <table class="table table-bordered" style="width: 100%;font-size: 13px;">
            <input type="hidden" name="id" value="{$data.id}">
            <tr>
                <td style="width: 30%;">是否设置过导购目标格式:</td>
                <td style="width: 70%;">已设置过导购目标格式，请查看导入格式是否正确：<a href="/index/ashippingguide/makeExcel?id={$data.id}">导购目标导入格式</a></td>
            </tr>
            <tr>
                <td style="width: 30%;">是否设置网点维度 <span class="colorRed">*</span>:</td>
                <td style="width: 70%;"><label class="radio-inline"><input type="radio" value="1" name="wd_dimension" class="form-control" id="is_true" {if condition="$data['wd_dimension'] == 1"}checked{/if}>是</label><label class="radio-inline"><input type="radio" value="0" name="wd_dimension" class="form-control" {if condition="$data['wd_dimension'] == 0"}checked{/if} id="is_no">否</label></td>
            </tr>
            <tr>
                <td style="width: 30%;">是否设置产品维度 <span class="colorRed">*</span>:</td>
                <td style="width: 70%;"><label class="radio-inline"><input type="radio" value="1" name="cp_dimension" class="form-control" id="isSetProduct" {if condition="$data['cp_dimension'] == 1"}checked{/if}>是</label><label class="radio-inline"><input type="radio" value="0" name="cp_dimension" {if condition="$data['cp_dimension'] == 0"}checked{/if} class="form-control" id="noSetProduct">否</label></td>
            </tr>
            <script>
                $('#isSetProduct').click(function () {
                    $('#productTr').show();
                });
                $('#noSetProduct').click(function () {
                    $('#productTr').hide();
                });
            </script>
            <tr id="productTr" {if condition="$data['cp_dimension'] == 0"}style="display: none"{/if}>
                <td style="width: 30%;">产品维度 <span class="colorRed">*</span>:</td>
                <td style="width: 70%;">
                    <select id="cp_type" name="cp_type" class="form-control select validate[required]">
                        <option value="">请选择</option>
                        <option value="0">品牌</option>
                        <option value="1">品类</option>
                        <option value="2">系列</option>
                        <option value="3">SKU</option>
                        <option value="4">单品</option>
                    </select>
                </td>
            <script>
                $('#cp_type').val("{$data['cp_type']}");
            </script>
            </tr>
            <tr id="cainianTr">
                <td style="width: 30%;">财年 <span class="colorRed">*</span>:</td>
                <td style="width: 70%;">
                    <select id="year" disabled="disabled" name="year" class="form-control select validate[required]">
                        <option value="{$data['year']}">{$data['year']}</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td style="width: 30%;">考核期维度 <span class="colorRed">*</span>:</td>
                <td style="width: 70%;">
                    <select id="kh_dimension" name="kh_dimension" class="form-control select validate[required]">
                        <option value="0">一级考核期</option>
                        <option value="1">二级考核期</option>
                    </select>
                    <script>
                        $('#kh_dimension').val("{$data['kh_dimension']}");
                    </script>
                </td>
            </tr>
        </table>
        <div class="text-center"><input type="button" value="保存" id="cp" class="btn btn-sm btn-primary"/><br/><br/><br/></div>
    </form>

</div>
<script>
    $('#f1').validationEngine('attach', {
        promptPosition: 'bottomRight'
    });
    $('#cp').click(function () {
        if($("#f1").validationEngine('validate')){
            $.ajax({
                'type':'post',
                'url':$("#f1").attr('action'),
                'data':$('#f1').serialize(),
                'dataType':'json',
                'success':function (data) {
                    if(data.success){
                            parent.location.reload();
                    }else
                        top.swal({
                            title: data.msg,
                            type: "warning"
                        });
                }
            });
            return false;
        }
    });
</script>
{/block}